package xyz.lwm.lazycat.utility.matcher;

/**
 * match target
 *
 * @author lwm
 */
public interface Matcher<T> {

    /**
     * matches
     *
     * @param target target
     * @return true if match
     */
    boolean matches(T target);

    /**
     * and
     *
     * @param matcher matcher
     * @return new matcher
     */
    default Matcher<T> and(Matcher<T> matcher) {
        return new AndMatcher<>(this, matcher);
    }

    /**
     * or
     *
     * @param matcher matcher
     * @return new matcher
     */
    default Matcher<T> or(Matcher<T> matcher) {
        return new OrMatcher<>(this, matcher);
    }

    /**
     * not
     *
     * @return new matcher
     */
    default Matcher<T> not() {
        return new NotMatcher<>(this);
    }

}
